# Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

# Azure Device Update example

set(example azure-netxduo-device-update)
set(supported_platforms corstone-300 corstone-310)

file(STRINGS intro.md EXAMPLE_INTRO NEWLINE_CONSUME)

foreach(platform IN LISTS supported_platforms)
    get_tfm_target_platform_variables(${platform})
    get_target_rtos_variables(threadx)
    set(EXAMPLE_TITLE "Azure Device Update example based on NetX Duo and PSA Firmware Update")
    set(EXAMPLE_RUN_COMMAND "${PLATFORM_VHT} -a __build/iotsdk-example-azure-netxduo-device-update_merged.elf -C mps3_board.smsc_91c111.enabled=1 -C mps3_board.hostbridge.userNetworking=1")
    set(example_dir ${EXAMPLES_OUTPUT_DIR}/${example}/${platform})
    configure_file(CMakeLists.txt.in ${example_dir}/CMakeLists.txt @ONLY)
    configure_file(${CMSIS_PACK_PLATFORM_CONFIG} ${example_dir}/cmsis-pack-platform.cmake @ONLY)
    configure_file(${README_TEMPLATE_FILE} ${example_dir}/README.md @ONLY)
    configure_file(${LINKER_SCRIPT_GCC} ${example_dir}/gcc.ld @ONLY)
    configure_file(${LINKER_SCRIPT_ARM} ${example_dir}/armclang.sct @ONLY)
    file(COPY
        main.c
        sample_azure_iot_embedded_sdk.c
        sample_azure_iot_credentials.h
        sample_config.h
        cert/nx_azure_iot_cert.c
        cert/nx_azure_iot_cert.h
        cert/nx_azure_iot_ciphersuites.c
        cert/nx_azure_iot_ciphersuites.h
        threadx-config
        netxduo-config

        initial_connection.log
        device_update.log
        .ci_hooks
        DESTINATION ${example_dir}
    )
    file(COPY
        cmsis-pack-platform/RTE/Device/${CMSIS_PACK_PLATFORM_DEVICE_NAME}
        DESTINATION ${example_dir}/cmsis-pack-platform/RTE/Device
    )
endforeach()
